//
//  TenderResultViewController.m
//  WBBaseProject
//
//  Created by 吴斌 on 2018/4/11.
//  Copyright © 2018年 吴斌. All rights reserved.
//

#import "TenderResultViewController.h"
#import "InvestTableViewCell.h"
#import "BidViewController.h"
#import "TendeResultView.h"
static NSString * const InvestTableViewCellReuseId = @"InvestTableViewCell";
@interface TenderResultViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
/** 消息数据 */
@property (nonatomic,strong) NSMutableArray *dataArr;
/** 消息数据 */
@property (nonatomic,strong) TendeResultView *resultView;
@end

@implementation TenderResultViewController

#pragma mark - 生命周期 Life Circle
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"投标成功";
    [self.view addSubview:self.tableView];
    
    [self registerCell];
    
    //    _page = 1;
    
    [self addRightButton];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    //    [self.comBoBoxView dimissPopView];
    self.navigationController.navigationBarHidden = NO;
    [WB_SharedApplication setStatusBarStyle:UIStatusBarStyleLightContent];
} 

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}


- (void)addRightButton
{
    UIButton *btn = [UIButton ba_buttonWithFrame:CGRectMake(0, 0, 80, 64) title:@"..." titleColor:[UIColor whiteColor] titleFont:[UIFont systemFontOfSize:30]];
    btn.transform = CGAffineTransformMakeRotation(-M_PI_2);
    btn.contentVerticalAlignment = UIControlContentVerticalAlignmentBottom;
    btn.titleLabel.textAlignment = NSTextAlignmentRight;
    btn.frame = CGRectMake(0, 0, 80, 64);
    //把视图的边角变为圆形, cornerRadius圆角半径
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    //弹簧控件, 修复边距
    UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
    spaceItem.width = -5;
    self.navigationItem.rightBarButtonItems = @[spaceItem,backItem];
    [btn addTarget:self action:@selector(clickRule:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)clickRule:(UIButton *)sender
{
    
}

- (void)registerCell
{
    [self.tableView registerNib:[UINib nibWithNibName:InvestTableViewCellReuseId bundle:nil] forCellReuseIdentifier:InvestTableViewCellReuseId];
}

#pragma mark - 懒加载  Lazy Load
- (UITableView *)tableView
{
    if (_tableView == nil) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - kNavigationBarHeight) style:UITableViewStylePlain];
        _tableView.backgroundColor = [UIColor whiteColor];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.tableFooterView = [UIView new];
        _tableView.tableHeaderView = self.resultView;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return _tableView;
}

- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return 2;
}

- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath { 
    InvestTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:InvestTableViewCellReuseId forIndexPath:indexPath];
    cell.data = _dataArr[indexPath.row];
    cell.bidClick = ^{
        BidViewController *vc = [[BidViewController alloc]init];
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
    };
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 135.f;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
}

- (TendeResultView *)resultView
{
    if (_resultView == nil) {
        _resultView = [[TendeResultView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 285)];
       
    }
    return _resultView;
}

- (NSMutableArray *)dataArr{
    if (_dataArr == nil) {
        _dataArr = [NSMutableArray array];
    }
    return _dataArr;
}


@end
